# 无图形版
# GovRptWordCloudv1.py
# import jieba
# import wordcloud
#
# f = open("config/hamet.txt", "r", encoding="utf-8")
#
# t = f.read()
# f.close()
# ls = jieba.lcut(t)
#
# txt = " ".join(ls)
#
# w = wordcloud.WordCloud(width=1000, height=700, background_color="white")
# print(txt)
# w.generate(txt)
# w.to_file("grwordcloud.png")


# 不规则图形版
#GovRptWordCloudv2.py
import jieba
import wordcloud
from scipy.misc import imread
mask = imread("config/chinamap.jpg")
excludes = { }
f = open("config/hamlet.txt", "r", encoding="utf-8")
t = f.read()
f.close()
ls = jieba.lcut(t)
txt = " ".join(ls)
w = wordcloud.WordCloud(\
    width = 1000, height = 700,\
    background_color = "white",
     mask = mask
    )
w.generate(txt)
w.to_file("config/grwordcloudm.png")